package com.kuangstudy.collection.list;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: Demo4
 * date: 2021/07/12 16:15:03
 *
 * @author zlk
 */
public class Demo4 {
    /**
     *ArrayList要移除掉集合中的对象需要重写对象的equals方法，根据地址来比较
     * @param args
     */
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        students.add(new Student("kk1",10));
        students.add(new Student("kk2",11));
        students.add(new Student("kk3",12));
        students.add(new Student("kk4",13));
        System.out.println(students);
        students.remove(new Student("kk1",10));
        System.out.println(students);
        System.out.println(students.contains(new Student("kk2",11)));

    }
}
